package PeterSheep.Utils;

import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

public abstract class PMapAddons {
    public static Object getMinObjectValue(Map<Integer, ?> scanTarget) {
        Collection<?> set = scanTarget.values();
        Object[] objects = set.toArray();
        Arrays.sort(objects);
        return objects[0];
    }

    public static Object getMinObjectKey(Map<Integer, ?> scanTarget) {
        Set<Integer> set = scanTarget.keySet();
        Object[] objects = set.toArray();
        Arrays.sort(objects);
        return objects[0];
    }

    public static Object getMaxObjectValue(Map<Integer, ?> scanTarget) {
        Collection<?> set = scanTarget.values();
        Object[] objects = set.toArray();
        Arrays.sort(objects);
        return objects[objects.length - 1];
    }

    public static Object getMaxObjectKey(Map<Integer, ?> scanTarget) {
        Set<Integer> set = scanTarget.keySet();
        Object[] objects = set.toArray();
        Arrays.sort(objects);
        return objects[objects.length - 1];
    }
}
